var app = angular.module('lmDetailApp',[]);
app.controller('lmDetailController',function($scope,$http){

    $scope.lid = $('#getLid').val();
    $http({
        method: 'POST',
        url: 'laboratory/getLaboratoryDetail.do',
        data: $.param({"lid":$scope.lid}),
        headers: { 'Content-Type': 'application/x-www-form-urlencoded'}
    }).then(function successCallback(response) {
        console.log(response);
        $scope.msg = response.data.lmsg;
        $scope.lname = $scope.msg.lname;
        $scope.lintroduce = $scope.msg.lintroduce;
        $scope.lresponsible =$scope.msg.lresponsible;
        $scope.lcapacity = $scope.msg.lcapacity;
        $scope.lstatus = $scope.msg.lstatus;
        console.log($scope.msg);
    }, function errorCallback(response) {
        console.log("获取实验室详情失败！");
    });

    /*更新课程操作*/
    $scope.updateLm = function () {

        $scope.lmdata = {lid:$scope.lid,
                        lname:$scope.lname,
                        lintroduce:$scope.lintroduce,
                        lresponsible:$scope.lresponsible,
                        lcapacity:$scope.lcapacity,
                        lstatus:$scope.lstatus};
        $http({
            method: 'POST',
            url: 'laboratory/updateLm.do',
            params: $scope.lmdata,
            headers: { 'Content-Type': 'application/x-www-form-urlencoded'}
        }).then(function successCallback(response) {
            console.log(response);
            $scope.isSuccess = response.data.isSuccess;
            if($scope.isSuccess){
                alert("更新成功");
                window.location.href = "/laboratorymsg.do";
            }else
                alert("更新失败");
        }, function errorCallback(response) {
            console.log("获取失败！");
        });
    };

    $scope.backTolmList = function () {
        window.location.href = "/laboratorymsg.do";
    };


});